package de.jabc.sib.bio.ebi;

import de.jabc.adapter.bio.ebi.Branches;
import de.jabc.adapter.bio.ebi.LightweightServiceAdapter;
import de.jabc.adapter.bio.ebi.ServiceAdapter;
import de.metaframe.jabc.framework.execution.ExecutionEnvironment;
import de.metaframe.jabc.framework.sib.annotation.SIBClass;
import de.metaframe.jabc.framework.sib.annotation.SIBStatus;
import de.metaframe.jabc.framework.sib.parameter.ContextExpression;
import de.metaframe.jabc.framework.sib.parameter.ContextKey;
import de.metaframe.jabc.sib.ServiceAdapterDescriptor;

/**
 * Calls the EBI's NCBI BLAST service.
 * 
 * @author anna-lena
 * @version $Revision: 3325 $ $Date: 2008-03-03 13:34:38 +0100 (Mon, 03 Mar
 *          2008) $
 */
@SIBClass("ebi-sibs/WuBlast")
@SIBStatus("IMPLEMENTED")
public class WuBlast extends AbstractSIB {

	/* Branches */
	public static final String[] BRANCHES = { Branches.DEFAULT, Branches.ERROR };

	/* Parameters */
	public ContextExpression Email = new ContextExpression("", String.class,
			false);
	public ContextExpression Title = new ContextExpression("", String.class,
			false);
	public ContextExpression Program = new ContextExpression("", String.class,
			false);
	public ContextExpression Exp = new ContextExpression("", String.class,
			false);
	public ContextExpression Alignments = new ContextExpression("",
			String.class, false);
	public ContextExpression Scores = new ContextExpression("", String.class,
			false);
	public ContextExpression Align = new ContextExpression("", String.class,
			false);
	public ContextExpression Matrix = new ContextExpression("", String.class,
			false);
	public ContextExpression Stats = new ContextExpression("",
			String.class, false);
	public ContextExpression Sensitivity = new ContextExpression("", String.class,
			false);
	public ContextExpression Topcombon = new ContextExpression("", String.class,
			false);
	public ContextExpression Viewfilter = new ContextExpression("", String.class,
			false);
	public ContextExpression Filter = new ContextExpression("", String.class,
			false);
	public ContextExpression Strand = new ContextExpression("", String.class,
			false);
	public ContextExpression Sort = new ContextExpression("", String.class,
			false);
	public ContextExpression Stype = new ContextExpression("", String.class,
			false);
	public ContextExpression Sequence = new ContextExpression("", String.class,
			false);
	public ContextExpression Database = new ContextExpression("", String.class,
			false);
	public ContextKey resultOut = new ContextKey("result_out", ContextKey.Scope.LOCAL,
			true);
	public ContextKey resultError = new ContextKey("result_error", ContextKey.Scope.LOCAL,
			true);
	public ContextKey resultSequence = new ContextKey("result_sequence", ContextKey.Scope.LOCAL,
			true);
	public ContextKey resultIDs = new ContextKey("result_ids", ContextKey.Scope.LOCAL,
			true);
	public ContextKey resultXml = new ContextKey("result_xml", ContextKey.Scope.LOCAL,
			true);

	/**
	 * @see de.metaframe.jabc.sib.CodeGeneratorBlock#execute(ExecutionEnvironment)
	 */
	public String execute(ExecutionEnvironment environment) {
		try {
			return ServiceAdapter.callWuBlast(environment, this.Email,
					this.Title, this.Program, this.Exp, this.Alignments,
					this.Scores, this.Align, this.Matrix, this.Stats,
					this.Sensitivity, this.Topcombon, this.Viewfilter, this.Filter,
					this.Strand, this.Sort, this.Stype, this.Sequence,
					this.Database, this.resultOut, this.resultError, this.resultSequence, this.resultIDs, this.resultXml);
		} catch (NoClassDefFoundError e) {
			return Branches.ERROR;
		}
	}

	/**
	 * @see de.metaframe.jabc.sib.Generatable#generate()
	 */
	public ServiceAdapterDescriptor generate() {
		return new ServiceAdapterDescriptor(LightweightServiceAdapter.class
				.getName(), "callWuBlast", "Email", "Title", "Program",
				"Exp", "Alignments", "Scores", "Align", "Matrix",
				"Stats", "Sensitivity", "Topcombon", "Viewfilter", "Filter",
				"Strand", "Sort", "Stype", "Sequence", "Database", "resultOut", "resultError", "resultSequence", "resultIDs", "resultXml");
	}

}
